<?php

/*
	FIXME: this is currently hardcoded to the tumbling team fyn website... needs to be GENERIC!

*/

	//var_dump( $_REQUEST );

	$backurl = $_REQUEST["backurl"];
	
	get_header();

	$orderid 		= $_REQUEST["orderid"];
	$dbOrder 		= new ttfOrdersDatabase( $orderid );
	$merchandiseid 	= $dbOrder->getValue( "merchandiseid" );
	$dbMerchandise 	= new ttfMerchandisesDatabase( $merchandiseid );	
	$ordertext 		= $dbMerchandise->getValue( "ordertext" );
		
	$c = new spDiv;

	// not really needed
	$page = new spPage;
	$page->spRenderDefaults();
	$c->addChild( $page );
	
	$heading = new spHeading(array(
		"content"	=> ttfL( "paymentconfirmationtitle" )
	));
	$c->addChild( $heading );
	
	$p = new spParagraph(array(
		"content" => ttfL( "paymentconfirmationinfo" )
	));
	
	$c->addChild( $p );
	
	$p = new spParagraph(array(
		"content" => "<b>".ttfL("paymentconfirmationorderdescription").":</b><br/>{$ordertext}"
	));
	$c->addChild( $p );
	
	$p = new spParagraph(array(
		"content"	=> "<i>".ttfL("paymentconfirmationthankyou")."</i>"
	));
	$c->addChild( $p );
	
	$but = new spButton(array(
		"title" 	=> ttfL( "buttonback" ),
		"type"		=> "redirect_url", 
		"url"		=> $backurl
	));
	$c->addChild( $but );
	
	$main = new spDiv(array(
		"id" => "main"
	));
	$content = new spDiv(array(
		"id" => "content",
		"class" => "post"
	));
	$main->addChild( $content );
	$content->addChild( $c );
	
	$main->render();
	
	// change status in order to processing
	$dbOrder->setPaymentStatus( spOrderDatabase::PAYMENT_STATUS_PROCESSING );
	$dbOrder->save();
	
	/////////////////////////////////
	// wordpress
	/////////////////////////////////
	
	wp_footer();
	
?>